package com.leyou.order.config;

import com.leyou.order.interceptors.PrivilegeHandlerInterceptor;
import com.leyou.order.interceptors.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 虎哥
 */
@Configuration
@EnableConfigurationProperties(JwtProperties.class)
public class MvcConfig implements WebMvcConfigurer {
    @Autowired
    private JwtProperties prop;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new UserInterceptor()).addPathPatterns("/order/**");

        registry.addInterceptor(new PrivilegeHandlerInterceptor(prop)).
                excludePathPatterns("/swagger-ui.html").
                excludePathPatterns("/address/**");

    }
}